/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entity;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.OneToMany;

/**
 *
 * @author Andy
 */
@Entity(name = "Location")
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public abstract class LocationEntity extends DataObjectEntity implements Serializable {

    private String areaCode;
    private String type;
//    @OneToMany(mappedBy = "location")
//    private Collection<LocationQuantityEntity> locationToQuantity = new ArrayList<LocationQuantityEntity>();
    //private boolean anyExpiring;

    public LocationEntity() {
        super();
    }

//    public void setAnyExpiring(boolean anyExpiring) {
//        this.anyExpiring = anyExpiring;
//    }

//    public boolean isAnyExpiring() {
//        System.out.println("In any expiring");
//        Date currentDate = new Date();
//        SimpleDateFormat sdfDate = new SimpleDateFormat("dd/MM/yyyy");
//        sdfDate.format(currentDate);
//        Calendar c = Calendar.getInstance();
//        c.setTime(currentDate);
//        c.add(Calendar.DATE, 30);  // number of days to add
//
//        List<LocationQuantityEntity> lqeList = new ArrayList<LocationQuantityEntity>(this.getLocationToQuantity());
//         System.out.println("In any expiring lqe size"+ lqeList.size());
//        for (LocationQuantityEntity lqe : lqeList) {
//            if (lqe.getInventory().getBatch().getExpiryDate().before(c.getTime()) && lqe.isArchived()==false) {
//                anyExpiring=true;
//                return anyExpiring;
//            }
//        }
//        anyExpiring=false;
//        return anyExpiring;
//    }

//    public Collection<LocationQuantityEntity> getLocationToQuantity() {
//        return locationToQuantity;
//    }
//
//    public void setLocationToQuantity(Collection<LocationQuantityEntity> locationToQuantity) {
//        this.locationToQuantity = locationToQuantity;
//    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getAreaCode() {
        return areaCode;
    }

    public void setAreaCode(String areaCode) {
        this.areaCode = areaCode;
    }

    @Override
    public String childToString() {
        return "LocationEntity{" + "areaCode=" + areaCode + '}';
    }
}
